
#include <stdint.h>
#include <string.h>

#include <Reader/ReaderISO14443.h>
#include "log/log2.h"

int Card_ExchangeApdu(uint8_t card, uint8_t capdu[], uint16_t clen, uint8_t* rapdu, uint16_t* rlen){
	if(card == 0){
		static uint8_t rbuf[256];
		uint16_t len = 0;
//			LOG2_BUF_DBG("capdu ", capdu, clen);
		int ret = Reader_ISO14443_4_Exchange(capdu, clen, rbuf, &len, 256);
		if(ret){
			return ret;
		}
//			LOG2_BUF_DBG("rapdu ", rbuf, len);
		if(rapdu){
			memcpy(rapdu, rbuf, len);
		}
		if(rlen){
			*rlen = len;
		}
		return ret;
	}
	return -1;
}



